package com.lc.luzhengtang.adapter;

import android.content.Intent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.lc.luzhengtang.R;
import com.lc.luzhengtang.activity.ShopDetailActivity;
import com.lc.luzhengtang.bean.PersonalShopListBean;
import com.lc.luzhengtang.conn.Conn;
import com.zcx.helper.scale.ScaleScreenHelperFactory;

import java.util.List;

/**
 * 文 件 名: NewsListAdapter
 * 创 建 人: zhangyu
 * 创建日期: 16/12/24 19:55
 * 邮   箱: yuanchong121@gmail.com
 * 修改时间：
 * 修改备注：
 */
public class PersonalShopListAdapter extends BaseQuickAdapter<PersonalShopListBean.DataBeanX.DataBean, BaseViewHolder> {
    TextView textView;
    public PersonalShopListAdapter(List<PersonalShopListBean.DataBeanX.DataBean> data) {

        super(R.layout.item_dianpu, data);
    }


    @Override
    protected void convert(BaseViewHolder helper, final PersonalShopListBean.DataBeanX.DataBean item) {
        ScaleScreenHelperFactory.getInstance().loadView((ViewGroup) helper.convertView);

        helper.setText(R.id.text_nicheng, item.getTitle());
        helper.setText(R.id.text_money, "¥" + item.getSales());
        helper.setText(R.id.text_xiaoliang, "销量：" + item.getVolume());
//        helper.setText(R.id.text_oldmoney, "￥" + item.getMarket_price());
        //  helper.setImageResource(R.id.img_index, Glide.with(mContext).load("").into(imageView) );
        Glide.with(mContext).load(Conn.HOST3 + item.getPicurl()).crossFade().error(R.mipmap.zhanwei).into((ImageView) helper.getView(R.id.img_index));
        helper.addOnClickListener(R.id.img_add_purchase);
        textView = helper.getView(R.id.text_oldmoney);
        int position = helper.getPosition();
        if (position % 2 == 1) {
            ScaleScreenHelperFactory.getInstance().loadViewMargin(helper.convertView.findViewById(R.id.ll_content), 15, 23, 15, 0);
        } else {
            ScaleScreenHelperFactory.getInstance().loadViewMargin(helper.convertView.findViewById(R.id.ll_content), 15, 23, 15, 0);
        }
//        textView.getPaint().setFlags(Paint.STRIKE_THRU_TEXT_FLAG);
        View view = helper.getConvertView();
        view.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
              /*  //   WebActivity.runActivity(mContext, model.desc, model.url);
                Intent intent = new Intent();
                intent.putExtra("goodstype_id", item + "");
                intent.setClass(mContext, ConsumptionActiivty.class);
                mContext.startActivity(intent);*/

                Intent intent = new Intent();
                intent.putExtra("goods_id", item.getId()+"");
                intent.setClass(mContext, ShopDetailActivity.class);
                mContext.startActivity(intent);
            }
        });

    }


}
